<link href="/static/admin/css/plugins/chosen/bootstrap-chosen.css" rel="stylesheet">
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-lg-10">
        <h2>网站设置</h2>
        <ol class="breadcrumb">
            <li class="breadcrumb-item">
                <a href="/">首页</a>
            </li>
            <li class="breadcrumb-item">
                <a href="/admin">后台</a>
            </li>
            <li class="breadcrumb-item active">
                <strong>网站设置</strong>
            </li>
        </ol>
    </div>
    <div class="col-lg-2">

    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-lg-6">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>网站配置
                    </h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-12 b-r">
                            <p>网站全局配置.</p>
                            <form role="form" id="form-site">
                                <div class="form-group  row"><label class="col-sm-2 col-form-label">网站标题</label>

                                    <div class="col-sm-10"><input type="text" class="form-control" name="WebTitle"
                                                                  value="{{.config.WebTitle}}">
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-lg-2 col-form-label">网站二级标题</label>
                                    <div class="col-lg-10"><input type="text" placeholder="请输入网站的二级标题"
                                                                  name="SecondaryTitle" class="form-control"
                                                                  value="{{.config.SecondaryTitle}}">
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-lg-2 col-form-label">网站LOGO</label>
                                    <div class="col-lg-10"><input type="text" placeholder="网站LOGO的资源地址" name="LogoUrl"
                                                                  class="form-control" value="{{.config.LogoUrl}}">
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-sm-2 col-form-label">网站关键字</label>
                                    <div class="col-sm-10"><input type="text" class="form-control" name="Keywords"
                                                                  value="{{.config.Keywords}}"> <span
                                                class="form-text m-b-none">.</span>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-sm-2 col-form-label">网站URL</label>

                                    <div class="col-sm-10"><input type="text" class="form-control"
                                                                  value="{{.config.WebUrl}}" name="WebUrl">
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-sm-2 col-form-label">版权信息</label>

                                    <div class="col-sm-10"><input type="text" class="form-control"
                                                                  value="{{.config.CopyRight}}" name="CopyRight">
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-sm-2 col-form-label">首页文章显示条目</label>

                                    <div class="col-sm-10"><input type="text" placeholder="placeholder" name="PageSize"
                                                                  class="form-control" value="{{.config.PageSize}}">
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-lg-2 col-form-label">网站描述</label>

                                    <div class="col-lg-10"><textarea class="form-control" rows="3"
                                                                     name="Description">{{.config.Description}}</textarea>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-lg-2 col-form-label">开启评论审核</label>
                                    <div class="col-lg-10">
                                        <select data-placeholder="是否开启评论审核" name="Comment"
                                                class="chosen-select form-control"
                                                tabindex="2">
                                            {{if eq "on" .config.Comment}}
                                                <option value="on" selected>开启</option>
                                                <option value="off">关闭</option>
                                            {{else}}
                                                <option value="off" selected>关闭</option>
                                                <option value="on">开启</option>
                                            {{end}}
                                        </select>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row"><label class="col-lg-2 col-form-label">选择主题</label>
                                    <div class="col-lg-10">
                                        <select data-placeholder="请选择一个主题" name="Theme"
                                                class="chosen-select form-control"
                                                tabindex="2">
                                            {{range $key,$value := .theme}}
                                                {{if eq $value $.config.Theme}}
                                                    <option value="{{$value}}" selected>{{$value}}</option>
                                                {{else}}
                                                    <option value="{{$value}}">{{$value}}</option>
                                                {{end}}
                                            {{end}}
                                        </select>
                                        <span class="form-text m-b-none">该功能需重启服务生效</span>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group row">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <button class="btn btn-primary btn-sm" type="button" id="siteInfo">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-lg-5">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>个人信息</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form id="form-user">
                        <p>用户相关信息配置.</p>
                        <div class="form-group row"><label class="col-lg-2 col-form-label">账号</label>
                            <div class="col-lg-10"><input type="text" placeholder="用户登陆账号" name="Author"
                                                          class="form-control" value="{{.config.Author}}">
                            </div>
                        </div>
                        <div class="form-group row"><label class="col-lg-2 col-form-label">密码</label>
                            <div class="col-lg-10"><input type="password" placeholder="用户登陆密码" name="Password"
                                                          class="form-control" value="{{.config.Password}}">
                            </div>
                        </div>
                        <div class="form-group row"><label class="col-lg-2 col-form-label">用户头像</label>
                            <div class="col-lg-10"><input type="text" placeholder="用户头像url地址" name="UserImageUrl"
                                                          class="form-control" value="{{.config.UserImageUrl}}">
                            </div>
                        </div>
                        <div class="form-group row"><label class="col-lg-2 col-form-label">用户邮箱</label>
                            <div class="col-lg-10"><input type="text" placeholder="用户的邮箱地址" name="UserEmail"
                                                          class="form-control" value="{{.config.UserEmail}}">
                            </div>
                        </div>
                        <div class="form-group row"><label class="col-lg-2 col-form-label">用户Github</label>
                            <div class="col-lg-10"><input type="text" placeholder="用户的Github地址" name="UserGithub"
                                                          class="form-control" value="{{.config.UserGithub}}">
                            </div>
                        </div>
                        <div class="form-group row"><label class="col-lg-2 col-form-label">联系QQ</label>
                            <div class="col-lg-10"><input type="text" placeholder="用户的QQ" name="UserQQ"
                                                          class="form-control" value="{{.config.UserQQ}}">
                            </div>
                        </div>
                        <div class="form-group row">
                            <div class="col-lg-offset-2 col-lg-10">
                                <button class="btn btn-sm btn-danger" type="button" id="userInfo">修改</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Chosen -->
<script src="/static/admin/js/plugins/chosen/chosen.jquery.js"></script>
<!-- layer -->
<script src="/static/admin/layer/layer.js"></script>
<script>
    $('.chosen-select').chosen({width: "100%"});
    $("#siteInfo").click(function () {
        const postData = $("#form-site").serialize();
        $.post("/api/site/config?submit=site", postData, function (res) {
            if (res.Error === 0) {
                layer.open({
                    skin: 'layer-class',
                    title: res.Title
                    , content: res.Msg,
                    yes: function (index) {
                        window.location.href = "/admin/setting/website";
                        layer.close(index); //如果设定了yes回调，需进行手工关闭
                    }
                });
            } else {
                layer.msg(res.Title + res.Msg, {time: 2000});
            }
        }, "json");
        return false;
    });
    $("#userInfo").click(function () {
        const postData = $("#form-user").serialize();
        $.post("/api/site/config?submit=user", postData, function (res) {
            if (res.Error === 0) {
                layer.open({
                    skin: 'layer-class',
                    title: res.Title
                    , content: res.Msg,
                    yes: function (index) {
                        window.location.href = "/admin/setting/website";
                        layer.close(index); //如果设定了yes回调，需进行手工关闭
                    }
                });
            } else {
                layer.msg(res.Title + res.Msg, {
                    icon: 2,
                    shade: [0.8, '#393D49'], // 透明度  颜色
                    time: 2000
                });
            }
        }, "json");
        return false;
    });
</script>